Developer Documentation

QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Finding a Drawing Engine

Not all drawing engines are capable of drawing into all type of virtual devices. For example, some drawing engines might not support memory devices at all, and other drawing engines might support only a particular graphics device. As a result, once you've initialized a virtual device, you need to find a drawing engine that is capable of drawing into that device. You do this by finding the available drawing engines and selecting one that is capable of drawing into the desired virtual device. If more than one engine supports that device, you need to choose one of them.

QuickDraw 3D versions 1.1 and later provide a control panel that allows the user to select the drawing engine to use for each available monitor.

You can search through the list of available drawing engines by calling the QADeviceGetFirstEngine and QADeviceGetNextEngine functions. The QADeviceGetFirstEngine function returns the preferred drawing engine for the specified device; in most cases, this engine is the best engine to use for high performance rendering. However, you might need specific drawing features that are not supported by the preferred drawing engine. If so, you can use the QAEngineGestalt function to query the engine's capabilities, as shown in Listing 6 .

Listing 6 Finding a drawing engine with fast texture mapping

TQAEngine *MyFindPreferredEngine (TQADevice *device)
{
    TQAEngine               *myEngine;
    unsigned long           fast;

    for (myEngine = QADeviceGetFirstEngine(device);
            myEngine;
            myEngine = QADeviceGetNextEngine(device, myEngine)) {
        if (QAEngineGestalt(myEngine, kQAGestalt_FastFeatures, &fast) == kQANoErr) {
            if (fast & kQAFast_Texture)
                return(myEngine);
        }
    }
    return(NULL);
}

The MyFindPreferredEngine function defined in Listing 6 calls the QADeviceGetFirstEngine function to get the preferred drawing engine for the specified device. Then it calls QAEngineGestalt , passing the kQAGestalt_FastFeatures selector, to determine which (if any) features are accelerated by that engine. If the engine supports accelerated texture mapping, the MyFindPreferredEngine function returns that drawing engine. Otherwise, the MyFindPreferredEngine function loops through all engines capable of drawing into the specified device until it finds one that does support fast texture mapping. If none is found, MyFindPreferredEngine returns the value NULL .

See "Gestalt Selectors" for a complete description of the selectors you can pass to the QAEngineGestalt function.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |